//    Copyright (C) Kherty.  All rights reserved.
using System;
using System.Globalization;
using System.Windows.Data;

namespace OpenLS.Spreadsheet.UI
{
    internal class BorderStyleToThicknessConverter : IValueConverter
    {
        #region IValueConverter Members

        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {
            var bs = (BorderStyle) value;
            return StyleToThickness(bs);
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            throw new NotSupportedException();
        }

        #endregion

        public static double StyleToThickness(BorderStyle style)
        {
            switch (style)
            {
                case BorderStyle.None:
                    return 0;
                case BorderStyle.Double:
                    return 1;
                case BorderStyle.Thick:
                    return 3;
                case BorderStyle.DashDot:
                case BorderStyle.DashDotDot:
                case BorderStyle.Dashed:
                case BorderStyle.Thin:
                    return 1;
                case BorderStyle.MediumDashDot:
                case BorderStyle.MediumDashDotDot:
                case BorderStyle.MediumDashed:
                case BorderStyle.Medium:
                    return 2;
                    case BorderStyle.Dotted:
                    return 1;
                    case BorderStyle.Hair:
                    return 1;
                    case BorderStyle.SlantDashDot:
                    return 2;

                default:
                    throw new NotSupportedException();
            }
        }
    }
}